<template>
	<view>
		<baseHead title="联系人信息" bg="#ffffff" color="#000000" text_right="保存" :right="true" @clickRight="clickRight">
		</baseHead>

		<view style="margin-top: 20rpx;">
			<view class="liaxr">
				<view>
					<text style="color:#f56c6c ; ">*</text>联系人
				</view>
				<view style="flex: 1;">
					<u-input placeholder="请输入内容" v-model="model.LinkManName" inputAlign="right" border="none">
					</u-input>
				</view>
			</view>

			<view class="liaxr">
				<view>
					<text style="color:#f56c6c ; ">*</text>联系手机
				</view>
				<view style="flex: 1;">
					<u-input placeholder="请输入内容" type="number" v-model="model.LinkManPhone" inputAlign="right" border="none">
					</u-input>
				</view>
			</view>

			<view class="liaxr">
				<view>
					<text style="color:#f56c6c ; ">*</text>企业热线
				</view>
				<view style="flex: 1;">
					<u-input placeholder="请输入内容" v-model="model.TelePhone" type="number" inputAlign="right" border="none">
					</u-input>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import baseHead from '@/pages/component/baseHead.vue'
	export default {
		data() {
			return {

				model: {
					LinkManName: "",
					LinkManPhone: "",
					TelePhone: "",

				}
			}
		},
		components: {
			baseHead
		},
		onLoad() {

		},
		created() {
			this.listdata();
		},
		methods: {
			listdata() {
				let qyid = uni.getStorageSync('dianjiqiye');
				this.$http.core.tenantgetall(qyid.Id).then(res => {
					if (res.Success) {
						console.log(res);
						this.model = res.Result;
					}

				})
			},
			clickRight() {
				console.log(this.model)

				if (!this.model.LinkManName) {
					this.$util.toast("请输入联系人");
					return;
				}
				if (!this.model.LinkManPhone) {
					this.$util.toast("请输入手机号");
					return;
				}
				if (!this.model.TelePhone) {
					this.$util.toast("请输入企业热线");
					return;
				}

				let email_reg = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
				if (email_reg.test(this.model.LinkManPhone)) {
					//修改
					this.$http.core.tenantupdate(this.model).then(res => {
						console.log(res);
						if (res.Success) {
							this.$util.toast("修改成功")
							setTimeout(() => {
								uni.navigateBack();
							}, 1000)
						}
					})
				} else {
					this.$util.toast("手机号错误")
				}

			},
		}
	}
</script>

<style>
	.liaxr {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 40rpx;
		background-color: #FFFFFF;
	}
</style>
